define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            Controller.api.bindevent();
            $('.left-bar-1 .item').click(function () {
                $('.left-bar-1 .item').removeClass('selected')
                // $('.left-bar-2 .item').removeClass('selected')
                $(this).addClass('selected')
                var type = $(this).data('type')
                $('.left-bar-2 .item').hide()
                $('.left-bar-2 [data-type='+type+']').show()
            })
            $('.left-bar-2 .item').click(function () {
                var keyno = $('#keyno').val()
                if (!keyno) {
                    Backend.api.toastr.error(__('请先输入需要查询企业的统一信用代码'));
                    return
                }
                $('.left-bar-2 .item').removeClass('selected')
                $(this).addClass('selected')
                $('.right-content').children().remove()
                $('.right-content').append('<div class="tx-center">查询信息中</div>')
                var method = $(this).data('method')
                $.ajax({
                    url: "pro/qcc/api",
                    data:{
                        keyNo:keyno,
                        type: method
                    },
                    success: function (res) {
                        console.log(res)
                        $('.right-content').children().remove()
                        $('.right-content').append(res)
                    },
                    error: function (res) {
                        console.log(res)
                        $('.right-content').children().remove()
                        $('.right-content').append('<div class="tx-center">查询失败,status:'+res.status+',statusText:'+res.statusText+'</div>')
                    }
                })
            })
            $('.left-bar-1 .item:first-child').click()
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});